package adapter

import (
	"context"
	"github.com/Shopify/sarama"
	"io"
)

type Adaptor interface {
	io.Closer
	NewConsumer(topic, groupId string) (c Consumer, err error)
	NewProducer() (p Producer, err error)
}
type base struct {
	ctx    context.Context
	cancel context.CancelFunc
}

func (b *base) init() {
	b.ctx, b.cancel = context.WithCancel(context.Background())
}

type Consumer interface {
	Get() <-chan *sarama.ConsumerMessage
	GetBatch(ctx context.Context, batch int) []*sarama.ConsumerMessage
}
type Producer interface {
	Input() chan<- *sarama.ProducerMessage

	// Errors is the error output channel back to the user. You MUST read from this
	// channel or the Producer will deadlock when the channel is full. Alternatively,
	// you can set Producer.Return.Errors in your config to false, which prevents
	// errors to be returned.
	Errors() <-chan *sarama.ProducerError
}
